﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace tools_library
{
    public partial class frmConfig : Form
    {
        public SerializableHashtable ht;

        public frmConfig(SerializableHashtable ht)
        {
            this.ht = ht;
            InitializeComponent();
        }


        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmConfig_Load(object sender, EventArgs e)
        {
            foreach (NameValuePair nvp in ht)
            {
                dgConfig.Rows.Add(new string[] { nvp.Key, nvp.Value.ToString() });
            }
        }

        private void dgConfig_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }

        private void dgConfig_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1) return;
            string key = dgConfig.Rows[e.RowIndex].Cells[0].Value.ToString();
            ht[key] = dgConfig.Rows[e.RowIndex].Cells[1].Value.ToString();
        }
    }
}
